
#include "stdafx.h"
#include "SysCallBack.h"


CSysCallBack::CSysCallBack(void)
{
}

CSysCallBack::~CSysCallBack(void)
{
}

BOOL 
CSysCallBack::QueryCallbackInfoList(
    CALLBACK_TYPE Type
)
{
    ULONG uRet, Length;
    BOOL bRet = TRUE;
    PVOID Buffer = NULL;
    PULONG callBackFunc;

    if (!m_hDriver){
        return FALSE;
    }

    do{
        bRet = DeviceIoControl(m_hDriver, IOCTL_EAGLEEYES_CALLBACK_LEN, 
            &Type, sizeof(Type), &Length, sizeof(ULONG), &uRet, NULL);
        if (!bRet || !Length){
            return FALSE;
        }

        if (Buffer){
            delete Buffer;
        }
        Buffer = new CHAR[Length];
        RtlZeroMemory(Buffer, Length);

        bRet = DeviceIoControl(m_hDriver, IOCTL_EAGLEEYES_CALLBACK_INFO, 
            NULL, 0, Buffer, Length, &uRet, NULL);
        if (!bRet && GetLastError() != 24){
            LoggingErrorString(_T("QueryProcessInfoList error! error code %d\n"), GetLastError());
            delete Buffer;
            return FALSE;
        }
    }while(GetLastError() == 24);

    callBackFunc = (PULONG)Buffer;

    for (ULONG i = 0; i < Length/sizeof(ULONG); i++){
        _tprintf(_T("id %d : callback Id: %08x\n"), i, callBackFunc[i]);
    }
	CAtlArray 
    return bRet;
}